package com.ymatou.iapi.spu.service;

import java.util.ArrayList;
import java.util.List;

import com.ymatou.iapi.productspu.parameter.SPUDTO;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.EnvSetup;
/**
*获取SPU列表
*FreeMaker Template自动生成代码
*/
public class QuerySPUListCall extends YmatouBaseCall{
	private static String opurl ="api/Spu/QuerySPUList";
	
	public QuerySPUListCall() {
		super(EnvSetup.getSystemUrl("productspu_iapi"),opurl,"GET","PARAM");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	public List<SPUDTO> getSPUs(){
		List<SPUDTO> spus=new ArrayList<>();
		getJsonObject().get("Result").getAsJsonObject().get("SPUList").getAsJsonArray().forEach(sspu->{
			SPUDTO spu = (SPUDTO) FormatUtil.GSONToObject(sspu.toString(),SPUDTO.class);
			spus.add(spu);
		});
		return spus;
		
	}
}